﻿namespace Probel.Ldoc.Views.ToolBoxes
{
    using System.Windows;

    using Probel.Ldoc.ViewModels.Pages;
    using Probel.Mvvm.DataBinding;
    using Probel.Mvvm.Gui;
    using Probel.Mvvm.Gui.FileServices;

    /// <summary>
    /// Interaction logic for ExtractPicturesView.xaml
    /// </summary>
    public partial class ExtractPicturesView : Window
    {
        #region Constructors

        public ExtractPicturesView(ExtractPicturesViewModel viewModel)
        {
            this.Owner = ViewService.RootWindow;
            InitializeComponent();
            this.DataContext = viewModel;

            this.ViewModel.Extracted += ViewModel_Extracted;
        }

        #endregion Constructors

        #region Properties

        private ExtractPicturesViewModel ViewModel
        {
            get { return this.DataContext as ExtractPicturesViewModel; }
        }

        #endregion Properties

        #region Methods

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Click_Cancel(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Click_ChoosePath(object sender, RoutedEventArgs e)
        {
            FileGuiFactory.Win32.SelectDirectory(p => this.ViewModel.ZipPath = p); ;
        }

        private void Click_Extract(object sender, RoutedEventArgs e)
        {
            this.btn_Cancel.IsEnabled
                = this.btn_Ok.IsEnabled
                = false;

            this.ViewModel.ExtractCommand.TryExecute();
        }

        private void ViewModel_Extracted(object sender, System.EventArgs e)
        {
            this.Close();
        }

        #endregion Methods
    }
}